﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BUS;
using DTO;
namespace GUI
{
    public partial class FormDatBan : Form
    {
        public static int ID_Khu_Vuc = 0;
        public static int ID_Ban_An = 0;
        public FormDatBan()
        {
            InitializeComponent();
            KhuVucBUS kv = new KhuVucBUS();
            List<KhuVucDTO> listKV = new List<KhuVucDTO>();
            listKV = kv.LayDanhSachKhuVuc();
            comboBox1.DataSource = listKV;
            comboBox1.DisplayMember = "Ten_Khu_Vuc";
            comboBox1.ValueMember = "Id_Khu_Vuc";
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

            ID_Khu_Vuc = Convert.ToInt32(comboBox1.SelectedValue.ToString());
            BanAnBUS ba = new BanAnBUS();
            List<BanAnDTO> ListBanAN = new List<BanAnDTO>();
            ListBanAN = ba.DanhSachBanAnTheoKhuVucConTrong(ID_Khu_Vuc);
            comboBox2.DataSource = ListBanAN;
            comboBox2.DisplayMember ="Ten_Ban_An";
            comboBox2.ValueMember = "Id_Ban_An";
            
        }

        private void FormDatBan_Load(object sender, EventArgs e)
        {
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;
            ID_Ban_An = Convert.ToInt32(comboBox2.SelectedValue.ToString());
            GioVaoBUS gvBUS = new GioVaoBUS();
            gvBUS.LuuGioVao(dt, ID_Ban_An);
            FormChonMonAn f = new FormChonMonAn();
            f.Show();
            this.Close();
            
            
        }

        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            //ID_Ban_An = Convert.ToInt32(comboBox2.SelectedValue.ToString());
        }

    }
}
